
/*

DEPENDENCIES:
-------------
Gimme.Effects
ext.get_style
ext.set_style
-------------


IN THIS FILE:
-------------
ext.fade_to
ext.fade_in
ext.fade_out
-------------

*/

(function()
{
	function fadeAni(start, end, duration, guid, callback, easing)
	{
		// IE hack to force "hasLayout"
		this.set_style({ zoom: 1 });
		
		if (start === null)
		{
			start = function(elem, prop)
			{
				return Number(Gimme(elem).get_style(prop));
			};
		}
		
		var sb = Gimme.Effects.Storyboard.create
		(
			// items to animate
			this,
			
			//from
			{ opacity: start },
			
			// to
			{ opacity: end },
			
			// animate function
			function(elem, props)
			{
				Gimme(elem).set_style({ opacity: props.opacity });
			},
			
			// duration
			duration,
			
			// guid
			guid,
			
			// callback
			callback,
			
			// easing
			null
		);
		
		sb.begin();
		return this;	
	}

	Gimme.ext.fade_to = fadeAni;
	//[AltSyntax]Gimme.ext.fadeTo = Gimme.ext.fade_to;
	
	Gimme.ext.fade_in = function(duration, guid, callback, easing)
	{
		return fadeAni.call(this, 0, 1, duration, guid, callback, easing);
	};
	//[AltSyntax]Gimme.ext.fadeIn = Gimme.ext.fade_in;
	
	Gimme.ext.fade_out = function(duration, guid, callback, easing)
	{
		return fadeAni.call(this, 1, 0, duration, guid, callback, easing);
	};
	//[AltSyntax]Gimme.ext.fadeOut = Gimme.ext.fade_out;
	
})();

